﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Option.Master" AutoEventWireup="true"
    CodeBehind="SelectDept.aspx.cs" Inherits="MsgCenter.Web.Pages.DeptManage.SelectDept"
    EnableViewState="false" EnableViewStateMac="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="headContent" runat="server">
    <link rel="stylesheet" media="screen" type="text/css" href="<%=ResolveClientUrl("~/JavaScript/Tree/tree.css") %>" />
    <script type="text/javascript" src="<%=ResolveClientUrl("~/JavaScript/Tree/tree.js") %>"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mailContent" runat="server">
    <div class="widget-box">
        <div class="input-group">
            选择的部门:<input type="text" id="txtSelectDept" readonly="readonly" />
            <button type="button" class="btn btn-info btn-sm" onclick="return SelectDept();">
                确定<i class="icon-ok bigger-110"></i>
            </button>
            <input type="hidden" id="Hidden1" runat="server" />
        </div>
        <div class="widget-header header-color-blue2">
            <h4 class="lighter smaller">
                部门列表</h4>
        </div>
        <div class="widget-body" style="height: 250px">
            <div class="widget-main padding-8">
                <div id="tree" style="height: 240px; overflow-x: no; overflow-y: auto;">
                    <img src="../../Images/tree/loading.gif" />
                </div>
            </div>
        </div>
    </div>
    <input type="hidden" id="hidDeptID" />
    <script type="text/javascript">
        function getCalendarData() {
            var trdata = null;
            $.ajax({
                type: "GET",
                url: "../../Handlers/Handler_Dept.ashx?method=GetDeptTree",
                async: false,
                success: function (msg)
                { trdata = msg; },
                error: function (msg) { }
            });
            return trdata;
        }
        function LoadTree() {
            var o = {
                cbiconpath: "../../Images/tree/",
                emptyiconpath: "../../Images/tree/s.gif",
                showcheck: false,
                onnodeclick: function (item) {
                    if (item.value != "00000000-0000-0000-0000-000000000000") {
                        $("#txtSelectDept").val(item.text);
                        $("#hidDeptID").val(item.value);
                    }
                    else {
                        $("#txtSelectDept").val("");
                        $("#hidDeptID").val("");
                    }
                }
            };
            var tre = getCalendarData();
            eval("var data =" + tre + ";");
            o.data = data;
            $("#tree").treeview(o);
        }
        $(document).ready(function () {
            LoadTree();
        });
        function SelectDept() {
            window.parent.SelectDeptValue($('#txtSelectDept').val(), $("#hidDeptID").val());
            return false;
        }
        
    </script>
</asp:Content>
